package com.example.client

import org.zeromq.ZMQ

object JeroMqClient {
    fun send() {
        val context = ZMQ.context(1) //I/O线程上下文的数量为1
        val socket = context.socket(ZMQ.REQ) //ZMQ.REQ表示这是一个request类型的socket
        socket.connect("tcp://127.0.0.1:8888") //连接到8888端口
        val now = System.currentTimeMillis()
        val request = "hello, time is $now"
        socket.send(request.toByteArray())
        val response = socket.recv()
        println("客户端 收到回复:\t" + String(response))
        //关闭
        socket.close()
        context.term()
    }
}